﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace QExcel
{
    public struct StyleEntity
    {
        /// <summary>
        /// 样式背景色
        /// </summary>
        public Color BgColor
        {
            get;
            set;
        }

        /// <summary>
        /// 字体颜色
        /// </summary>
        public Color FontColor
        {
            get;
            set;
        }

        /// <summary>
        /// 是否粗体
        /// </summary>
        public bool IsBold
        {
            get;
            set;
        }
    }

    public class ExcelCommon
    {
        /// <summary>
        /// 将string格式的颜色改成Color对象
        /// </summary>
        /// <param name="colorValue"></param>
        /// <returns></returns>
        public static Color GetColorFromString(string colorValue)
        {
            string[] sqlit = colorValue.Split(',');
            if (sqlit.Length == 3)
            {
                try
                {
                    return Color.FromArgb(Int32.Parse(sqlit[0]), Int32.Parse(sqlit[1]), Int32.Parse(sqlit[2]));
                }
                catch
                {
                }
            }
            else
            {
                try
                {
                    return Color.FromName(colorValue);
                }
                catch
                {
                }
            }
            return Color.FromArgb(0, 0, 0, 0);
        }
    }
}
